package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.assemble.pojo.dto.AssembleDeleteBatchDTO;
import com.xbongbong.pro.assemble.pojo.dto.AssembleEditAttrUpdateDTO;
import com.xbongbong.pro.assemble.pojo.dto.AssembleUpdateByBusinessRuleDTO;
import com.xbongbong.pro.assemble.pojo.vo.AssembleDeleteBatchVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.listbatch.pojo.dto.AddLabelDTO;
import com.xbongbong.pro.product.pojo.dto.PagingProductDTO;
import com.xbongbong.pro.product.pojo.vo.PagingProductVO;
import com.xbongbong.saas.domain.entity.AssembleProductEntity;
import com.xbongbong.saas.domain.entity.ProductBaseInfoEntity;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;

import java.util.List;

/**
 * @author Jian.Wang
 * @version v1.0
 * @date 2019/1/22 10:39
 * @since v1.0
 */
public interface AssembleService {
    /**
     * 装配单保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 装配单保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @author Jian.Wang
     * @date 2019/1/23 20:00
     * @since v1.0
     * @throws XbbException 异常
     **/
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;


    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/3/5 19:23
     * @param assembleDeleteBatchDTO
     * @return com.xbongbong.pro.assemble.pojo.vo.AssembleDeleteBatchVO
     * @throws XbbException 业务异常
     */
    AssembleDeleteBatchVO deleteBatch(AssembleDeleteBatchDTO assembleDeleteBatchDTO) throws XbbException;

    /**
     * 批量编辑某个字段
     * @author 吴峰
     * @date 2019/3/20 14:40
     * @param assembleEditAttrUpdateDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void batchEditAttr(AssembleEditAttrUpdateDTO assembleEditAttrUpdateDTO) throws XbbException;
    /***  
     * 获取装配单产品
     * @author 吴峰  
     * @date 2019/4/5 15:04
     * @param businessProductListDTO
     * @param object
     * @return com.xbongbong.pro.businessproduct.pojo.vo.BusinessProductListVO
     * @throws XbbException 业务异常       
     */  
//    BusinessProductListVO getAssembleProductList(BusinessProductListDTO businessProductListDTO, Object object) throws XbbException;

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     * @author lee
     * @date 2019/4/29 14:16
     * @since V1.0
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 格式化导出值
     *
     * @param paasFormDataESList 数据
     * @throws XbbException 异常
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, FormDataListDTO formDataListDTO, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * Description: 装配出入库单 仓库一致性同步
     * @param corpid
     * @param dataId
     * @param name
     * @return void
     * @author 魏荣杰
     * @date 2019/8/5 10:25
     * @since v1.0
     */
    void dataConsistencyUpdateWarehouse(String corpid, Long dataId, String name) throws XbbException;

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, Boolean forProcess, Integer operate, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    PagingProductVO getPagingProduct(PagingProductDTO pagingProductDTO) throws XbbException;

    JSONObject formatSingleProduct(AssembleProductEntity entity,ProductBaseInfoEntity productBaseInfoEntity);

    void validateDataOutProduct(JSONArray outProductArray, JSONArray inProductArray, String corpid, Long outWarehouseId) throws XbbException;

    /**
     * 根据业务规则，更新装配出入库单
     * @author 吴峰
     * @date 2019/8/19 16:11
     * @param assembleUpdateByBusinessRuleDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void updateBatchByBusinessRule(AssembleUpdateByBusinessRuleDTO assembleUpdateByBusinessRuleDTO) throws XbbException;

    void formatBatchExplain(List<FieldAttrEntity> fieldAttrEntityList, String enable);

    void updateBatchLabelAttr(AddLabelDTO addLabelDTO, List<PaasFormDataEntityExt> addBatchList, Boolean addOrDelete) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO);

    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;
}
